import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { BaseItem } from "../../common/BaseItem";
import { SWFPlayer } from "../../../scene/modle/SWFPlayer";
import { ModelType } from "../../../scene/modle/data/ModelType";
import { GiftBagInfo } from "../../../model/GiftBagInfo";
import { ItemData } from "../../../resource/info/ItemData";
import { FlyToNavbarTool } from "../../award/FlyToNavbarTool";
//class OpenSeverNewGoodRender
    
    export  class OpenSeverNewGoodRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            this._bg = GlobalClass.getBitmap(ImagesConst.PackItemBg);
            addChild(this._bg);
            this._item = new BaseItem();
            this._item.setSize(32, 32);
            this._item.x = 3;
            this._item.y = 3;
            addChild(this._item);
            this._effectPlayer = new SWFPlayer();
            this._effectPlayer.load("ItemShowEffect.swf", ModelType.Effect, null);
            this._effectPlayer.move(48, 58);
            this.addChild(this._effectPlayer);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if ((arg1.info as GiftBagInfo).item) 
            {
                this._item.itemData = arg1.info.item as ItemData;
                this._effectPlayer.timeRate = 1;
                this._effectPlayer.play();
            }
            else 
            {
                this.removeChild(this._effectPlayer);
            }
            if (arg1.flyFlag) 
            {
                this.flyPack();
                arg1.flyFlag = false;
            }
            return;
        }

        public flyPack(): void
        {
            FlyToNavbarTool.flyToBackPack(this._item.bitmapdata, localToGlobal(new Object /* flash.geom.Point */(this._item.x, this._item.y)));
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_item: BaseItem;

        /* internal */ /* var */_effectPlayer: SWFPlayer;
    }
